package com.itheima.reggie.mapper;

import com.itheima.reggie.entity.ShoppingCart;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface ShoppingCartMapper {

    //更新购物车，
    void Update(ShoppingCart shoppingCart1);

    //根据用户id, 菜品id , 套餐id来查看数据
    ShoppingCart findByUserIdAndDishIdAndSetmealId(ShoppingCart shoppingCart);

    @Insert("Insert into shopping_cart values(  null , #{name} , #{image} ,  #{userId} ,  #{dishId} , #{setmealId} , #{dishFlavor} , #{number} , #{amount} , #{createTime} )")
    void addShoppingCart(ShoppingCart shoppingCart);

    @Select("SELECT * FROM shopping_cart where user_id = #{userId};")
    List<ShoppingCart> selectByUserId(Long userId);

    //删除购物车的数据，根据用户id
    @Delete("DELETE FROM shopping_cart WHERE user_id = #{userId};")
    void deleteByUserId(Long userId);
}
